package com.usian.service;

import com.usian.dao.CategoryMapper;
import com.usian.pojo.Category;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryService {

    @Autowired
    private CategoryMapper categoryMapper;

    public List<Category> findAll() {
        return categoryMapper.selectAll();
    }

    public void add(Category category) {
        categoryMapper.insertSelective(category);
    }

    public void del(Integer id) {
        categoryMapper.deleteByPrimaryKey(id);
    }

    public Category findById(Integer id) {
        Category category = categoryMapper.selectByPrimaryKey(id);
        return category;
    }

    public void update(Category category) {
        categoryMapper.updateByPrimaryKeySelective(category);
    }


//    public Category findById(Integer id) {
//
//        List<Category>categorys= categoryMapper.findById(id);
//        if (categorys!=null){
//            return categorys.get(0);
//        }
//        return null;
//    }

//    public void edit(Category category) {
//        categoryMapper.edit(category);
//    }



}
